package sz.szsmk.citizencard.model.network.bean;

import com.alipay.sdk.packet.e;

import java.util.HashMap;
import java.util.Map;

/**
 * @author : hyt
 * @date : 2021/10/21
 * @description : 农行SDK 返回
 */
public class AbcPayResult {

    private boolean isSuccess = false;
    private Map<String,String> result;

    public AbcPayResult(String param) {
        //TokenID=16348047722583990419  &  STT=9999  &  Msg=

        try{
            String[] map = param.split("&");
            //map[0] =  TokenID=16348047722583990419
            result = new HashMap<>();

            for(int i=0;i<map.length;i++){
                String[] temp = map[i].split("=");
                if(temp.length==2 &&  temp[1]!=null){
                    result.put(temp[0],temp[1]);
                }else{
                    result.put(temp[0],"");
                }
            }

            if(result.containsKey("STT")){
                switch (result.get("STT")){
                    case "0000":
                        isSuccess = true;
                        break;
                    default:
                        isSuccess = false;
                        break;
                }
            }


        }catch (Exception ex){
            isSuccess = false;
            ex.printStackTrace();
        }


    }

    public boolean isSuccessful() {
        return isSuccess;
    }

    public String getMsg() {
        return result.get("Msg");
    }


    public String getSTT() {
        return result.get("STT");
    }
}
